// ArgumentParser.h: interface for the CArgumentParser class.
//
//////////////////////////////////////////////////////////////////////

class CHelper;

class CArgumentParser
{
public:
	bool isValidOption(char cOption);//To check whether an option is valid or not
	CArgumentParser(char* strSyntax);//To initialize with syntax

	int parse(int& optc, char **argv);//Parse the command line
	bool wasParseSuccessful();//Returns result of parse-attempt 
	bool wasOptionSupplied(char cOption);//Returns whether option was supplied
	char* getField(char cOption);//Returns string supplied for option
	virtual ~CArgumentParser();//Destructor to take care of deallocation
	void fillHelpForOption(char cOption, char* strValue);

	CHelper* m_Helper;		//Help-related functions

protected:
	bool m_bWasParseSuccess;//Did operate result in a valid-parse
	bool m_bIsInOptionMode;
	bool m_bWasThereMoreToFill;

	char* m_strSyntax;		//Syntax of the options
	char* m_strSyntaxWorkingCopy; //Working copy of syntax, modified during parse
	bool* m_abSupplied; //Working copy of syntax, modified during parse

	int m_nOptions;			//Number of options

	char* m_strOption;		//Stores the options 
	char** m_straValue;		//Stores the value for the options

	static const char cArgumentSpecifier;	//Character which specifies value essential in syntax
	static const char cOptionPrefix;		//Character which WILL be followed by an option
	
protected:
	bool isValueEssentialForOption(char cOption);//Checks whether option takes a value
	int indexOfOption(char c);//Returns index of the option
	void invalidateOption(char c);//Marks the option as used by removing it from working copy of syntax
	char* getField(int nPos, char& cOption);//Returns value in nPos position
	void fillValueForOption(char cOption, char *strValue);//Fills the value for option
	bool fillArrayForOption(char cOption,char**paArray,char*strValue);

};

